﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Mongaba.Core;
using Mongaba.Core.Registers;
using Mongaba.Core.ServiceContracts;

namespace Mongaba
{
    internal delegate void frmCreateGroupFillCompletedHandle(string userName, string groupName);

    internal partial class frmCreateGroup : Form
    {
        internal event frmCreateGroupFillCompletedHandle frmCreateGroupFillCompleted;

        public frmCreateGroup()
        {
            InitializeComponent();
            this.Icon = Properties.Resources.Mongaba;
            txtName.Focus();            
        }

        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtName.Text) || String.IsNullOrEmpty(txtGroup.Text))
            {
                MessageBox.Show("Você deve informar seu nome de usuário e o nome do grupo para continuar");
                return;
            }

            frmCreateGroupFillCompleted(txtName.Text, txtGroup.Text);
            this.Hide();
        }

        private void frmCreateGroup_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                e.Cancel = true;
                this.Hide();
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void frmCreateGroup_Shown(object sender, EventArgs e)
        {
            txtName.Focus();
        }
    }
}
